# -*- coding: utf-8 -*-
class Singleton(type):
    def __init__(cls, *args, **kwargs):
        cls.__instance = None
        super().__init__(*args, **kwargs)

    def __call__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance = super().__call__(*args, **kwargs)
        return cls.__instance


class User(metaclass=Singleton):
    def __init__(self, name):
        self.name = name


if __name__ == '__main__':
    user1 = User(name='jack')
    user2 = User(name='tom')
    print(user1.name)
    print(user2.name)
    print(id(user1))
    print(id(user2))
